package com.ymatou.iapi.couponservice.testcase;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponservice.parameter.CouponDto;
import com.ymatou.iapi.couponservice.parameter.getProductAvailablePlatformCouponListBean;
import com.ymatou.iapi.couponservice.service.getProductAvailablePlatformCouponListCall;
import com.ymatou.iapi.m.couponservice.parameter.CreateCouponBean;
import com.ymatou.iapi.m.couponservice.service.CreateCouponCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceCallService;
import com.ymttest.business.service.CouponServiceMCallService;
import com.ymttest.utils.TestDataManager;
/**
*获取商品可用的平台优惠券列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getProductAvailablePlatformCouponList{
	private static getProductAvailablePlatformCouponListBean getproductavailableplatformcouponlistBean;
	private static getProductAvailablePlatformCouponListCall getproductavailableplatformcouponlistCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品可用的平台优惠券列表");
	}

	@Before
	public void caseUp() {
		getproductavailableplatformcouponlistBean=new getProductAvailablePlatformCouponListBean();
		getproductavailableplatformcouponlistCall=new getProductAvailablePlatformCouponListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getproductavailableplatformcouponlistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_001() {
		Logger.start(true,"获取商品可用的平台优惠券列表");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	            createcouponBean.setProductIds(productIds);

			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createcouponBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = couponServiceCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			Thread.sleep(5*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");

  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");

				}
			}
  			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_002() {
		Logger.start(true,"获取商品可用的平台优惠券列表-多张可聚合券");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	            createcouponBean.setProductIds(productIds);

			CreateCouponCall createCouponCall1 = couponCallService.createPlatformCoupon(createcouponBean);
			CreateCouponCall createCouponCall2 = couponCallService.createPlatformCoupon(createcouponBean);

			Thread.sleep(3000);
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = couponServiceCallService.receiveCouponInfo(createCouponCall1.getBatchCode(), userId);
			Thread.sleep(1000);
			String couponCode2 = couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);

			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode1), "验证couponCode1返回");
  			Logger.verifyEquals(false,isCouponCodeContain(couponDtos,couponCode2), "验证couponCode2不返回");

  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode1)||couponDto.getCouponCode().equals(couponCode2))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(2,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");

				}
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_003() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券可用面额不等不聚合");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	            createcouponBean.setProductIds(productIds);

			CreateCouponCall createCouponCall1 = couponCallService.createPlatformCoupon(createcouponBean);
			
			CreateCouponBean createcouponBean2 = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean2.setProductIds(productIds);
			createcouponBean2.getCouponValues().get(0).setDeductionMaxAmount(new BigDecimal(5));
			CreateCouponCall createCouponCall2 = couponCallService.createPlatformCoupon(createcouponBean2);

			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = couponServiceCallService.receiveCouponInfo(createCouponCall1.getBatchCode(), userId);
			String couponCode2 = couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);

			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode1), "验证couponCode1返回");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode2), "验证couponCode2返回");
  		
  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode1))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");
				}
				
				if(couponDto.getCouponCode().equals(couponCode2))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean2.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds")   ;
				}
			}
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_004() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券使用面额不等不聚合");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();
    
			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			
			String productId = TestDataManager.getRandomNum(8);
			 
			List<String> productIds = new ArrayList<String>();
			productIds.add(productId);
			productIds.add("qaffsfsewrwer");
			productIds.add("qaffsfswerwqerqwrqw");
	        
			 createcouponBean.setProductIds(productIds);

			CreateCouponCall createCouponCall1 = couponCallService.createPlatformCoupon(createcouponBean);
			
			CreateCouponBean createcouponBean2 = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean2.setProductIds(productIds);
			createcouponBean2.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(150));
			CreateCouponCall createCouponCall2 = couponCallService.createPlatformCoupon(createcouponBean2);

			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = couponServiceCallService.receiveCouponInfo(createCouponCall1.getBatchCode(), userId);
			String couponCode2 = couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);

			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode1), "验证couponCode1返回");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode2), "验证couponCode2返回");
  		
  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode1))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");
				}
				
				if(couponDto.getCouponCode().equals(couponCode2))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean2.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds")   ;
				}
			}
  			
  			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_005() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券限制条件不等不聚合");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();
    
			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			
			String productId = TestDataManager.getRandomNum(8);
			 
			List<String> productIds = new ArrayList<String>();
			productIds.add(productId);
			productIds.add("qaffsfsewrwer");
			productIds.add("qaffsfswerwqerqwrqw");
	        
			 createcouponBean.setProductIds(productIds);
			 
			List<Integer> categories = new ArrayList<>();
			
			categories.add(123);
			createcouponBean.setCategories(categories);

			CreateCouponCall createCouponCall1 = couponCallService.createPlatformCoupon(createcouponBean);
			
			CreateCouponBean createcouponBean2 = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean2.setProductIds(productIds);
			createcouponBean2.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(150));
			CreateCouponCall createCouponCall2 = couponCallService.createPlatformCoupon(createcouponBean2);

			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = couponServiceCallService.receiveCouponInfo(createCouponCall1.getBatchCode(), userId);
			String couponCode2 = couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);

			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(123);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode1), "验证couponCode1返回");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode2), "验证couponCode2返回");
  			
  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode1))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(4,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(1,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");
				}
				
				if(couponDto.getCouponCode().equals(couponCode2))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean2.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds")   ;
				}
			}
  			
  			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_006() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券使用结束时间不等不聚合");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();
    
			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			
			String productId = TestDataManager.getRandomNum(8);
			 
			List<String> productIds = new ArrayList<String>();
			productIds.add(productId);
			productIds.add("qaffsfsewrwer");
			productIds.add("qaffsfswerwqerqwrqw");
	        
		    createcouponBean.setProductIds(productIds);
			 
			Calendar calendar2 = Calendar.getInstance(); // 得到日历
			calendar2.setTime(new Date());// 把当前时间赋给日历
			calendar2.add(Calendar.DAY_OF_MONTH, 3); // 设置为后十天
			Date dAfter = calendar2.getTime(); // 得到前一天的时间

			createcouponBean.setValidEnd(dAfter);
			
			CreateCouponCall createCouponCall1 = couponCallService.createPlatformCoupon(createcouponBean);
			
			CreateCouponBean createcouponBean2 = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			createcouponBean2.setProductIds(productIds);
			createcouponBean2.getCouponValues().get(0).setOrderMinAmount(new BigDecimal(150));
			CreateCouponCall createCouponCall2 = couponCallService.createPlatformCoupon(createcouponBean2);

			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = couponServiceCallService.receiveCouponInfo(createCouponCall1.getBatchCode(), userId);
			String couponCode2 = couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);

			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode1), "验证couponCode1返回");
  			Logger.verifyEquals(true,isCouponCodeContain(couponDtos,couponCode2), "验证couponCode2返回");

  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode1))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");
				}
				
				if(couponDto.getCouponCode().equals(couponCode2))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean2.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean2.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean2.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds")   ;
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_007() {
		Logger.start(true,"获取商品可用的平台优惠券列表-UserType空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			//getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("userType must 1 or 2",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_008() {
		Logger.start(true,"获取商品可用的平台优惠券列表-UserId空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			//getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("userId must",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_009() {
		Logger.start(true,"获取商品可用的平台优惠券列表-CategoryIds空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			//getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("categoryIds size is must equals 3",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_010() {
		Logger.start(true,"获取商品可用的平台优惠券列表-PlatformId空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			//getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("platformId must",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_011() {
		Logger.start(true,"获取商品可用的平台优惠券列表-CountryId空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			//getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("0",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_012() {
		Logger.start(true,"获取商品可用的平台优惠券列表-SellerId空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			//getproductavailableplatformcouponlistBean.setSellerId(233);
			getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("sellerId must",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_013() {
		Logger.start(true,"获取商品可用的平台优惠券列表-ProductCode空");
		try {
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(122);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(233);
			//getproductavailableplatformcouponlistBean.setProductCode("dsfgdfg");       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
  			Logger.verifyEquals("1",getproductavailableplatformcouponlistCall.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains("productCode must",getproductavailableplatformcouponlistCall.getString("message"), "验证返回message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_014() {
		Logger.start(true,"获取商品可用的平台优惠券列表-stress");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	         createcouponBean.setProductIds(productIds);
	         
	         List<CreateCouponCall> createCouponCallList = new ArrayList<>();
	         
	         for(int i=0;i<20;i++)
	         {
	        	 createCouponCallList.add(couponCallService.createPlatformCoupon(createcouponBean));
	         }
	         
			Integer userId=TestDataManager.getRandomIntNum(8);
			
			for (CreateCouponCall createCouponCall2 : createCouponCallList) {
				 couponServiceCallService.receiveCouponInfo(createCouponCall2.getBatchCode(), userId);
			}
			
			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_015() {
		Logger.start(true,"获取商品可用的平台优惠券列表-JIRACONN-15448:ymt_couponprivateuserbound表冗余了validstart, validend字段，作废优惠券时未更新validstart字段，导至优惠券作废后依然可以显示在商详页：用户可用的平台优惠券列表中");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	            createcouponBean.setProductIds(productIds);

			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createcouponBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = couponServiceCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			couponCallService.InvalidPlatformBatch(createCouponCall.getBatchCode(),"123","ttt");
			
			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);       

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(1,couponDtos.size(), "验证返回couponDtos数量");

  			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_016() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优选商品-优选优惠券");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
			 List<String> productIds = new ArrayList<String>();
			 productIds.add(productId);
			 productIds.add("qaffsfsewrwer");
			 productIds.add("qaffsfswerwqerqwrqw");
	            createcouponBean.setProductIds(productIds);
	            
	            createcouponBean.setLimitPspProduct(true);

			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createcouponBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = couponServiceCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);   
			getproductavailableplatformcouponlistBean.setPsp(true);

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(true,couponDtos.size()>0, "验证返回couponDtos数量");

  			for (CouponDto couponDto : couponDtos) {
				if(couponDto.getCouponCode().equals(couponCode))
				{
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					

		  			Logger.verifyEquals(1,couponDto.getQuantity(), "验证返回quantity");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
		  			Logger.verifyEquals(formatter.format(createcouponBean.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getDeductionMaxAmount(),couponDto.getCouponValue(), "验证返回couponValue");
		  			Logger.verifyEquals(createcouponBean.getCouponValues().get(0).getOrderMinAmount(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
		  			Logger.verifyEquals(2,couponDto.getLimitType(), "验证返回limitType");
		  			Logger.verifyEquals(createcouponBean.getUserType(),couponDto.getLimitUserType(), "验证返回limitUserType");
		  			Logger.verifyEquals(0,couponDto.getLimitCategoryIds().size(), "验证返回limitCategoryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitCountryIds().size(), "验证返回limitCountryIds");
		  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");

				}
			}
  			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductAvailablePlatformCouponList_017() {
		Logger.start(true,"获取商品可用的平台优惠券列表-普通商品-优选优惠券");
		try {
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			CouponServiceCallService couponServiceCallService = new CouponServiceCallService();

			// 平台优惠券-链接
			CreateCouponBean createcouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForRecieve();	
			String productId = TestDataManager.getRandomNum(8);
	
	            createcouponBean.setLimitPspProduct(true);

			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createcouponBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = couponServiceCallService.receiveCouponInfo(createCouponCall.getBatchCode(), userId);
			
			Thread.sleep(3*1000);
			
			List<Integer> categoryIds = new ArrayList<>();			
			categoryIds.add(111);	
			categoryIds.add(222);	
			categoryIds.add(333);	
			
			getproductavailableplatformcouponlistBean.setUserType(1);
			getproductavailableplatformcouponlistBean.setUserId(userId);
			getproductavailableplatformcouponlistBean.setCategoryIds(categoryIds);
			getproductavailableplatformcouponlistBean.setPlatformId(1);
			getproductavailableplatformcouponlistBean.setCountryId(1);    
			getproductavailableplatformcouponlistBean.setSellerId(createcouponBean.getOperatorId());
			getproductavailableplatformcouponlistBean.setProductCode(productId);   
			getproductavailableplatformcouponlistBean.setPsp(false);

			getproductavailableplatformcouponlistCall.setData(getproductavailableplatformcouponlistBean);
			getproductavailableplatformcouponlistCall.callService();
			
			List<CouponDto> couponDtos = getproductavailableplatformcouponlistCall.GetProductAvailablePlatformCouponResp().getCouponDtos();
			
  			Logger.verifyEquals(0,couponDtos.size(), "验证返回couponDtos数量");

  			for (CouponDto couponDto : couponDtos) {
  				Logger.verifyEquals(false, couponDto.getCouponCode().equals(couponCode), "验证优选商品券没有返回出来");
			}
  			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private boolean isCouponCodeContain(List<CouponDto> couponDtos,String couponCode)
	{
		for (CouponDto couponDto : couponDtos) {
			if(couponDto.getCouponCode().equals(couponCode))
				return true;
		}
		return false;
	}
}